<template>
  <div class="app-container">
    <ht-search-form
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
    />

    <ht-table
      ref="dataTable"
      :multi-select="false"
      :showSerialNumber="false"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
      :reqConfig="regConfig"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="50" fixed="right">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog :title="title" center  :visible.sync="open" width="1024px" append-to-body :close-on-click-modal="true">
      <el-form ref="detailForm" :model="detailForm" :rules="rules" label-width="120px" :disabled="true">
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>基本信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="交易流水号" prop="id">
                <el-input v-model="detailForm.id" :disabled="true" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="内部机构号" prop="brno">
                <el-select style="width: 100%" v-model="detailForm.brno" placeholder="内部机构号" :disabled="true">
                  <el-option
                    v-for="dict in dictMap['Cnaps2Dict.CP2_BRNO']"
                    :key="dict.value"
                    :label="`${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="报文标识号" prop="pkgId">
                <el-input v-model="detailForm.pkgId" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="系统编号" prop="sysCode">
                <el-select style="width: 100%" v-model="detailForm.sysCode" placeholder="系统编号" :disabled="true">
                  <el-option
                    v-for="dict in dictMap.SYS_CODE_310_312"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="CPG日期" prop="vdate">
                <el-date-picker
                  v-model="detailForm.vdate"
                  style="width: 100%"
                  type="date"
                  value-format="yyyyMMdd"
                  :disabled="true"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="工作日期" prop="workDate">
                <el-date-picker
                  v-model="detailForm.workDate"
                  style="width: 100%"
                  type="date"
                  value-format="yyyyMMdd"
                  :disabled="true"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="发起参与机构号" prop="sender">
                <el-input v-model="detailForm.sender" :disabled="true" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="发起参与机构名称" prop="senderName">
                <el-input v-model="detailForm.senderName" :disabled="true" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="接收参与机构" prop="rcver">
                <el-input v-model="detailForm.rcver" :disabled="true" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="接收参与机构名" prop="rcverName">
                <el-input v-model="detailForm.rcverName" :disabled="true" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原交易流水号" prop="oriId">
                <el-input v-model="detailForm.oriId" :disabled="true" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="原报文标识号" prop="oriPkgId">
                <el-input v-model="detailForm.oriPkgId" :disabled="true" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="备注" prop="remarks">
                <el-input type="textarea" v-model="detailForm.remarks" :disabled="true" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>处理信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="通讯状态" prop="status">
                <el-select style="width: 100%" v-model="detailForm.status" placeholder="通讯状态">
                  <el-option
                    v-for="dict in dictMap.COM_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="中心状态" prop="procStatus">
                <el-select style="width: 100%" v-model="detailForm.procStatus" placeholder="中心状态">
                  <el-option
                    v-for="dict in dictMap.PROCESSSTATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="报文发送时间" prop="reqSendtime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.reqSendtime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="通用报文处理码" prop="processCode">
                <el-select
                  style="width: 100%"
                  v-model="
                    detailForm.processCode === null || detailForm.processCode === undefined
                      ? ''
                      : detailForm.processCode + '-' + detailForm.processCodeDesc
                  "
                  placeholder="通用报文处理码"
                  :disabled="true"
                ></el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="录入操作员" prop="reqMdTlrno">
                <el-input v-model="detailForm.reqMdTlrno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="录入时间" prop="reqMdTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.reqMdTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="审核操作员" prop="audTlrno">
                <el-input v-model="detailForm.audTlrno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="审核时间" prop="audTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.audTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="审核附言" prop="audRemarks">
                <el-input type="textarea" v-model="detailForm.audRemarks" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="业务状态" prop="cp2Status">
                <el-select style="width: 100%" v-model="detailForm.cp2Status" placeholder="业务状态">
                  <el-option
                    v-for="dict in dictMap.CP2_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>业务撤销应答信息</span>
          </div>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="业务处理码" prop="bizProCode">
                <el-select
                  style="width: 100%"
                  v-model="
                    detailForm.bizProCode === null || detailForm.bizProCode === undefined
                      ? ''
                      : detailForm.bizProCode + '-' + detailForm.bizProCodeDesc
                  "
                  placeholder="业务处理码"
                  :disabled="true"
                ></el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="撤销处理状态" prop="remProStatus">
                <el-select style="width: 100%" v-model="detailForm.remProStatus" placeholder="撤销处理状态">
                  <el-option
                    v-for="dict in dictMap.PROCESSSTATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="撤销日期" prop="remDate">
                <el-date-picker v-model="detailForm.remDate" style="width: 100%" type="date" value-format="yyyyMMdd" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="应答时间" prop="resRcvtime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.resRcvtime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="业务处理信息" prop="bizProMesg">
                <el-input type="textarea" v-model="detailForm.bizProMesg" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>

      <div slot="footer" class="dialog-footer" align="center">
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { apiUrlConfigQuery, businessUndoQueryDetail } from "@/api/cnaps/ccms/307";
import { listPageMixin } from "@/libs/listPageMixin";
import HtAmountInput from "@/views/components/HtAmountInput";
import AmountRangeSearch from "@/views/components/AmountSearchInput";
export default {
  name: "BusinessUndoApprove",
  mixins: [listPageMixin],
  components: { HtAmountInput, AmountRangeSearch },
  data() {
    return {
      // 查询参数
      queryParams: {
        sysNo: "HVPS",
        id: undefined,
        brno: undefined,
        cpgDate1: undefined,
        cpgDate2: undefined,
        workDate1: undefined,
        workDate2: undefined,
        oriId: undefined,
      },
      // 搜索
      formOptions: [],
      //
      searchFormDictList: ["Cnaps2Dict.CP2_BRNO", "SYS_CODE_310_312", "PROCESSSTATUS", "COM_STATUS", "CP2_STATUS"],
      // 列信息
      regConfig: apiUrlConfigQuery,
      tableBindColumns: [
        {
          prop: "brno",
          label: "内部机构号",
          dictCode: "Cnaps2Dict.CP2_BRNO",
          sortable: false,
        },
        {
          prop: "id",
          label: "交易流水号",
          width: 180,
        },
        {
          prop: "sysCode",
          label: "系统编号",
          dictCode: "SYS_CODE_310_312",
          width: 180,
        },
        {
          prop: "vdate",
          label: "CPG日期",
          type: "date",
        },
        {
          prop: "workdate",
          label: "工作日期",
          type: "date",
        },
        {
          prop: "sender",
          label: "发起参与机构号",
          width: 180,
        },
        {
          prop: "rcver",
          label: "接收参与机构号",
          width: 180,
        },
        {
          prop: "oriPkgtype",
          label: "原报文类型",
          formatter(row, text, index) {
            return row["oriPkgtype"] + "-" + row["oriPkgtypeDesc"];
          },
          width: 240,
        },
        {
          prop: "oriId",
          label: "原交易流水号",
          width: 180,
        },
        {
          prop: "procStatus",
          label: "中心状态",
          dictCode: "PROCESSSTATUS",
        },
      ],
      loading: false,
      dictMapAsync: {},
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      detailForm: {
        amount: 0.0,
      },
      totalRecord: 0,
      totalPage: 0,
      needCount: 0,

      rules: {},
    };
  },
  mounted() {
    const formOptions = [
      // 普通搜索

      {
        type: "input",
        prop: "id",
        defaultAttr: {
          size: "small",
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },

      {
        type: "search-dept-tree",
        prop: "brno",
        defaultAttr: {
          radio: false,
          linkParentChoose: false,
          label: "分行选择",
          placeholder: "请选择分行",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgDate1",
          endTimeName: "cpgDate2",
        },
        defaultAttr: {
          size: "small",
          label: "CPG日期",
          placeholder: ["请输入CPG开始日期", "请输入CPG结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "workDate1",
          endTimeName: "workDate2",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作开始日期", "请输入工作结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "input",
        prop: "oriId",
        defaultAttr: {
          size: "small",
          label: "原交易流水号",
          placeholder: "请输入原交易流水号",
        },
      },
    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */
    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
      }
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },

    /** 详情按钮操作 */
    handleDetail(row) {
      this.title = "业务撤销申请查询明细";
      businessUndoQueryDetail(row).then((response) => {
        this.detailForm = response.result;
        this.open = true;
      });
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
